package com.td.framework.webmanager.page;

public class PageService {
	/**
	 * 取得分页信息
	 * @param 总条数
	 * @param 当前页
	 * @param 要执行的分页操作
	 * @param  每页显示的条数
	 * @return
	 */
    public static Page getPage(int totalRows,int currentPage,int pageSize,String pageMethod){
    	if(currentPage==0){
    		currentPage = 1;
    	}
    	if(pageSize ==0){
    		pageSize = 10;
    	}
    	if("".equals(pageMethod) || pageMethod==null){
    		pageMethod="first";
    	}
		Page page =new Page(totalRows,currentPage,pageSize);
    	if("first".equals(pageMethod)){
			page.first();
		}else if("previous".equals(pageMethod)){
			page.previous();
		}else if("next".equals(pageMethod)){
			page.next();
		}else if("last".equals(pageMethod)){
			 page.last();
		}else if("go".equals(pageMethod)){
			 page.go();
		}
    	return page;
    }
}
